﻿// Spun AJAX Framework
// Copyright (C) 2008 Blake Hegerle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spun.Communications.Applications;
using Spun;
using Spun.Controllers;
using Spun.Communications;
using Spun.Models.Prototyping;
using Spun.Models.Sequences;
using Spun.Communications.Hosting;

namespace SpunStarter
{
    public interface IModel
    {
        string Name { get; set; }
    }

    public class Controller : IController
    {
        public Controller()
        {
            var Model = App.NameNew<IModel>("Model");
            Model.Name = "Hello, world!";
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var HostString = Host.HOST_WILDCARD;
            short Port = 80;
            var VDir = "spunstarter";

            try
            {
                using (Terminal.Start<Controller>(HostString, Port, VDir, "Foo"))
                {
                    if (HostString == Host.HOST_WILDCARD)
                        HostString = "localhost";

                    Console.WriteLine("Running at http://{0}:{1}/{2}", HostString, Port, VDir);
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e);
            }
        }
    }
}

